package treemodel.line;

import document.Context;
import treemodel.Line;
import treemodel.Node;
import treemodel.Unit;
import treeview.NodeView;
import treeview.container.HorizontalContainer;

import java.util.ArrayList;

/**
 * Created by Pavel Nikolaev
 */
public class GeneralLine implements Line {
    protected ArrayList<Unit> myUnits;

    public GeneralLine() {
        this.myUnits = new ArrayList<Unit>();
    }

    public void add(Unit unit) {
        myUnits.add(unit);
    }

    public void prepareForWrapping() {
    }

    public NodeView createView(Context context) {
        HorizontalContainer container = new HorizontalContainer();
        for (Unit unit : myUnits) container.add(unit.createView(context));
        return container;
    }

    public int countChildren() {
        return myUnits.size();
    }

    public Node getChild(int index) {
        return myUnits.get(index);
    }
}
